{include file="public/header" /}
<style>
    .new_dl {
        margin-right: 10px !important;
    }
</style>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>供应商商品管理</h3>
                <h5></h5>
            </div>
            {include file="public/admin_items" /}
        </div>
    </div>
    <div class="fixed-empty"></div>
    <form method="get" name="formSearch" id="formSearch">
        <div class="ds-search-form">
            <dl class="new_dl">
                <dt>商品名称：</dt>
                <dd><input  type="text" value="{$Request.get.search_goods_name|default=''}" name="search_goods_name"
                           id="search_goods_name" class="txt"></dd>
            </dl>
            <dl class="new_dl">
                <dt>{$Think.lang.search_commonid}</dt>
                <dd><input type="text" style="width: 70px;" value="{$Request.get.search_commonid|default=''}" name="search_commonid"
                           id="search_commonid" class="txt"/></dd>
            </dl>
            <dl class="new_dl">
                <dt>{$Think.lang.goods_index_class_name}</dt>
                <dd id="searchgc_td"></dd>
                <input type="hidden" id="choose_gcid" name="choose_gcid" value="0"/>
            </dl>
            <dl class="new_dl">
                <dt>供应商名称：</dt>
                <dd><input type="text" style="width: 70px;" value="{$Request.get.search_store_name|default=''}" name="search_store_name"
                           id="search_store_name" class="txt"></dd>
            </dl>
            <dl class="new_dl">
                <dt>审核时间：</dt>
                <dd>
                    <input class="txt date" style="width: 63px;" type="text" value="{$Request.param.search_check_time}" id="search_check_time" name="search_check_time">
                </dd>
            </dl>
            <!--审核状态-->
            {if $type == 'allgoods'}

            <dl class="new_dl">
                <dt>{$Think.lang.goods_verify}</dt>
                <dd>
                    <select name="goods_verify" style="height: 30px;line-height: 30px;width:81px; ">
                        <option value="">{$Think.lang.ds_please_choose}...</option>
                        {foreach name="verify" item="val" key="key"}
                        <option value="{$key}" {$Request.param.goods_verify == $key && $Request.param.goods_verify !="" ? 'selected' : ''}>{$val}</option>
                        {/foreach}
                    </select>
                </dd>

            </dl>
            {/if}

            <dl class="new_dl">
                <dt>{$Think.lang.goods_index_brand}</dt>
                <dd>
                    <div id="ajax_brand" class="dssc-brand-select w180">
                        <div class="selection">
                            <input name="b_name" id="b_name" value="{$Request.param.b_name|default=''}" type="text"
                                   class="txt w180" readonly="readonly"/>
                            <input type="hidden" name="b_id" id="b_id" value="{$Request.param.b_id|default=''}"/>
                        </div>
                        <div class="dssc-brand-select-container">
                            <div class="brand-index" data-url="{:url('Common/ajax_get_brand')}">
                                <div class="letter" dstype="letter">
                                    <ul>
                                        <li><a href="javascript:void(0);" data-letter="all">全部</a>
                                        </li>
                                        <li><a href="javascript:void(0);" data-letter="A">A</a></li>
                                        <li><a href="javascript:void(0);" data-letter="B">B</a></li>
                                        <li><a href="javascript:void(0);" data-letter="C">C</a></li>
                                        <li><a href="javascript:void(0);" data-letter="D">D</a></li>
                                        <li><a href="javascript:void(0);" data-letter="E">E</a></li>
                                        <li><a href="javascript:void(0);" data-letter="F">F</a></li>
                                        <li><a href="javascript:void(0);" data-letter="G">G</a></li>
                                        <li><a href="javascript:void(0);" data-letter="H">H</a></li>
                                        <li><a href="javascript:void(0);" data-letter="I">I</a></li>
                                        <li><a href="javascript:void(0);" data-letter="J">J</a></li>
                                        <li><a href="javascript:void(0);" data-letter="K">K</a></li>
                                        <li><a href="javascript:void(0);" data-letter="L">L</a></li>
                                        <li><a href="javascript:void(0);" data-letter="M">M</a></li>
                                        <li><a href="javascript:void(0);" data-letter="N">N</a></li>
                                        <li><a href="javascript:void(0);" data-letter="O">O</a></li>
                                        <li><a href="javascript:void(0);" data-letter="P">P</a></li>
                                        <li><a href="javascript:void(0);" data-letter="Q">Q</a></li>
                                        <li><a href="javascript:void(0);" data-letter="R">R</a></li>
                                        <li><a href="javascript:void(0);" data-letter="S">S</a></li>
                                        <li><a href="javascript:void(0);" data-letter="T">T</a></li>
                                        <li><a href="javascript:void(0);" data-letter="U">U</a></li>
                                        <li><a href="javascript:void(0);" data-letter="V">V</a></li>
                                        <li><a href="javascript:void(0);" data-letter="W">W</a></li>
                                        <li><a href="javascript:void(0);" data-letter="X">X</a></li>
                                        <li><a href="javascript:void(0);" data-letter="Y">Y</a></li>
                                        <li><a href="javascript:void(0);" data-letter="Z">Z</a></li>
                                        <li><a href="javascript:void(0);" data-letter="0-9">{$Think.lang.goods_index_other}</a>
                                        </li>
                                    </ul>
                                </div>
                                <div class="search" dstype="search"><input name="search_brand_keyword"
                                                                           id="search_brand_keyword" type="text"
                                                                           class="text"/><a href="javascript:void(0);"
                                                                                            class="dssc-btn-mini"
                                                                                            style="vertical-align: top;">Go</a>
                                </div>
                            </div>
                            <div class="brand-list" dstype="brandList">
                                <ul dstype="brand_list">
                                    {notempty name="brand_list"}
                                    {foreach name="brand_list" item="val"}
                                    <li data-id='{$val.brand_id}' data-name='{$val.brand_name}'>
                                        <em>{$val.brand_initial}</em>{$val.brand_name}
                                    </li>
                                    {/foreach}
                                    {/notempty}
                                </ul>
                            </div>
                            <div class="no-result" dstype="noBrandList" style="display: none;">
                                {$Think.lang.no_brand_result}
                            </div>
                        </div>
                    </div>
                </dd>
            </dl>

            <dl>
                <dd><input style="height: 30px;line-height: 30px;" type="hidden" name="type" value="{$Request.param.type}"></dd>
                <dd> <a style="height: 30px;line-height: 30px;" href="javascript:void(0);" id="dssubmit" class="btn " title="{$Think.lang.ds_query}">{$Think.lang.ds_query}</a></dd>
                <dd><a style="height: 28px;line-height: 28px;" href="{:url('Product/index',['type'=>$Request.param.type])}" class="btn btn-default"
                       title="{$Think.lang.ds_cancel}">{$Think.lang.ds_cancel}</a></dd>
            </dl>

            <div class="btn_group">



            </div>
        </div>
    </form>


    <table class="ds-default-table">
        <thead>
        <tr class="thead">
            <th class="w24"></th>
            <th class="w60 align-center">{$Think.lang.search_commonid}</th>
            <th colspan="2">商品</th>
            <th>{$Think.lang.goods_index_brand}&{$Think.lang.goods_index_class_name}</th>
            <th class="w72 align-center">{$Think.lang.goods_verify}</th>
            <th class="w72 align-center">审核时间</th>
            <!--<th class="w72 align-center">提交时间</th>-->
            <th class="w72 align-center">审核人</th>
            {if $type == 'allgoods'}
            <th class="w72 align-center">{$Think.lang.ds_sort}</th>
            {/if}
            {if $type == 'lockup'}
            <th class="w72 align-center">审核未通过原因</th>
            {/if}

            <th class="w300 align-center">{$Think.lang.ds_handle}</th>
        </tr>
        </thead>


        <tbody>
        {notempty name="goods_list"}
        {foreach name="goods_list" item="v"}
        <tr class="hover edit" id="ds_row_{$v.goods_commonid}">
            <td></td>
            <td>{$v.goods_commonid}</td>
            <td class="w60 picture">
                <div class="size-56x56">
                    <span class="thumb size-56x56">
                        <i></i>
                   {if condition="(goods_thumb($v, 240)!='')"}
                      <img src="{:goods_thumb($v, 240)}" onload="javascript:ResizeImage(this,56,56);"/>
                 {else}
                         <img src="http://33wang.douyinhot.com/03a18202002091420493484.jpg"  onload="javascript:ResizeImage(this,56,56);"/>
                  {/if}
                </span>
                </div>
            </td>
            <td>
                <dl class="goods-info">
                    <dt class="goods-name">{$v.goods_name}</dt>
                    <dd class="goods-type">
                        {if $v.is_virtual eq 1}<span class="virtual">{$Think.lang.ds_virtual}</span>{/if}
                        {if $v.is_goodsfcode eq 1}<span class="fcode">{$Think.lang.ds_fcode}</span>{/if}
                        {if $v.is_presell eq 1}<span class="presell">{$Think.lang.ds_presell}</span>{/if}
                        {if $v.is_appoint eq 1}<span class="appoint">{$Think.lang.ds_appoint}</span>{/if}
                    </dd>
                    <dd class="goods-store">{if
                        isset($ownShopIds[$v['store_id']])}{$Think.lang.ds_platform}{else/}{/if}供应商：{$v.store_name}
                    </dd>
                </dl>
            </td>
            <td>
                <p>{$v.class_name}</p>
                <p class="goods-brand">{$Think.lang.ds_brand}：{$v.brand_name}</p>
            </td>
            <td class="align-center">{:isset($verify[$v['goods_status']]) ? $verify[$v['goods_status']] : $v['goods_status']}</td>
            <td>{:isset($v.check_time) ? $v.check_time : date('Y-m-d H:i:s', $v.goods_addtime)}</td>
            <!--<td>{:date('Y-m-d H:i:s', $v.goods_addtime)}</td>-->
            <td>{$v.check_by_name}</td>
            {if $type == 'allgoods'}
            <td class="align-center sort">
                <span class="editable" ds_type="inline_edit" fieldname="mall_goods_sort" ajax_branch='mall_goods_sort'
                      fieldid="{$v.goods_commonid}" datatype="pint" maxvalue="999999999999999999" title="{$Think.lang.ds_editable}">{$v.mall_goods_sort}</span>
            </td>
            {/if}
            {if $type == 'lockup'}
            <td class="align-center"><p class="goods-brand">{$v.goods_stateremark}</p></td>
            {/if}
            <td class="align-center">

                <a href="javascript:void(0);" onclick="goods_setting_info_jia({$v['goods_commonid']});"
                   class="dsui-btn-view">
                    <p>查看详情</p>
                </a>
                {if $v.goods_status == '0'}
                <a href="javascript:void(0);" onclick="goods_setting_price({$v['goods_commonid']});"
                   class="dsui-btn-edit"><i class="iconfont"></i>设置价格并审核</a>
                {/if}
                 {if $v.goods_status == '1'}
                <!-- 编辑价格 --> <a href="javascript:void(0);" onclick="edit_goods_price({$v['goods_commonid']});" class="dsui-btn-edit">编辑价格</a>
                {/if}

                {if $v.goods_status != '2'}
                <!-- 教程管理 --> <a href="javascript:void(0);" onclick="goods_setting_course({$v['goods_commonid']});" class="dsui-btn-edit">{$Think.lang.course_list}</a>
                {/if}
            </td>
        </tr>
        <tr style="display:none;">
            <td colspan="20">
                <div class="dssc-goods-sku ps-container"></div>
            </td>
        </tr>
        {/foreach}
        {else /}
        <tr class="no_data">
            <td colspan="15">{$Think.lang.ds_no_record}</td>
        </tr>
        {/notempty}
        </tbody>
        <tfoot>
        <tr class="tfoot">
            &nbsp;&nbsp;
            {if $type == 'lockup'}
            <td></td>
            <td colspan="16"></td>
            {elseif $type == 'waitverify'}
            <td></td>
            <td colspan="16"></td>
            {elseif $type == 'allgoods' /}
            <td></td>
            <td colspan="16"></td>
            {/if}
        </tr>
        </tfoot>
    </table>
    {$show_page}
</div>
<script type="text/javascript" src="{$Think.ADMIN_SITE_ROOT}/js/jquery.edit.js" charset="utf-8"></script>
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/jquery.mousewheel.js"></script>
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/mlselection.js" charset="utf-8"></script>

<script type="text/javascript">
    var HOMESITEURL = "{$Think.HOME_SITE_URL}";

    //查看详情
    function goods_setting_info_jia(ids_str) {
        _uri = ADMINSITEURL + "/Product/goods_setting_info?commonid=" + ids_str;
        dsLayerOpen(_uri, '查看详情', '100%', '100%');
    }

    $(function () {
        //商品分类
        init_gcselect({$gc_choose_json}, {$gc_json});
        /* AJAX选择品牌 */
        $("#ajax_brand").brandinit();

        $('#dssubmit').click(function () {
            $('#formSearch').submit();
        });

        // 违规下架批量处理
        $('a[dstype="lockup_batch"]').click(function () {
            ids_str = getItems();
            if (ids_str) {
                goods_lockup(ids_str);
            }
        });

        // ajax获取商品列表
        $('i[dstype="ajaxGoodsList"]').click(
            function () {

                var status = $(this).attr("status");
                if (status == 'open') {
                    $(this).attr('status', 'close');
                    $(this).removeClass('icon-jia').addClass('icon-jian');
                    var _parenttr = $(this).parents('tr');
                    var _commonid = $(this).attr('data-comminid');
                    var _div = _parenttr.next().find('.dssc-goods-sku');
                    if (_div.html() == '') {
                        $.getJSON('{:url("Goods/get_goods_list_ajax")}', {commonid: _commonid}, function (date) {
                            if (date != 'false') {
                                var _ul = $('<ul class="dssc-goods-sku-list"></ul>');
                                var res = eval('(' + date + ')');
                                for (var i = 0; i < res.length; i++) {
                                    $('<li><div class="goods-thumb" title="{$Think.lang.goods_serial}：' + res[i].goods_serial + '"><a href="' + res[i].url + '" target="_blank"><image src="' + res[i].goods_image + '" ></a></div>' + res[i].goods_spec + '<div class="goods-price">{$Think.lang.goods_price}：<em title="￥' + res[i].goods_price + '">￥' + res[i].goods_price + '</em></div><div class="goods-storage">{$Think.lang.goods_storage}：<em title="' + res[i].goods_storage + '">' + res[i].goods_storage + '</em></div><a href="' + res[i].url + '" target="_blank" class="dssc-btn-mini">{$Think.lang.show_goods_detail}</a></li>').appendTo(_ul);
                                    _ul.appendTo(_div);
                                    _parenttr.next().show();
                                }

                                // 计算div的宽度
                                _div.css('width', document.body.clientWidth - 54);

//                        _div.perfectScrollbar();
                            }
                        });
                    } else {
                        _parenttr.next().show()
                    }
                } else {
                    $(this).attr('status', 'open');
                    $(this).removeClass('icon-jian').addClass('icon-jia');
                    $(this).parents('tr').next().hide();
                }

            }
        );
    });

    // 获得选中ID
    function getItems() {
        /* 获取选中的项 */
        var items = '';
        $('.checkitem:checked').each(function () {
            items += this.value + ',';
        });
        if (items != '') {
            items = items.substr(0, (items.length - 1));
        } else {
            layer.alert('{$Think.lang.please_select_input}', {icon: 2})
        }
        return items;
    }

    // 商品下架
    function goods_lockup(ids_str) {
        _uri = ADMINSITEURL + "/Goods/goods_lockup?commonid=" + ids_str;
        dsLayerOpen(_uri, '{$Think.lang.goods_index_lock_reason}', '400px', '200px');
    }

    //商品设置平台价格
    function goods_setting_price(ids_str) {
        _uri = ADMINSITEURL + "/Product/goods_setting_price?commonid=" + ids_str;
        dsLayerOpen(_uri, '{$Think.lang.ds_setting_price}', '100%', '100%');
    }

     //编辑在售商品价格
    function edit_goods_price(ids_str) {
        _uri = ADMINSITEURL + "/Product/goods_setting_price?commonid=" + ids_str +"&is_edit=1";
        dsLayerOpen(_uri, '{$Think.lang.ds_setting_price}', '100%', '100%');
    }

    //商品设置教程
    function goods_setting_course(ids_str) {
        _uri = ADMINSITEURL + "/Product/goods_setting_course?commonid=" + ids_str;
        dsLayerOpen(_uri, '设置教程', '100%', '100%');
    }

    function submit_delete(ids_str) {
        _uri = ADMINSITEURL + "/Goods/goods_del.html?common_id=" + ids_str;
        dsLayerConfirm(_uri, '{$Think.lang.ds_ensure_del}');
    }
</script>

<script>
    $('#search_check_time').datepicker({dateFormat: 'yy-mm-dd'});
    $('#search_add_time').datepicker({dateFormat: 'yy-mm-dd'});
</script>


{include file="public/footer" /}
